#include "pch.h"
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

bool comp(int a, int b)
{
	string stra = to_string(a);
	string strb = to_string(b);

	if (stra + strb > strb + stra)
		return true;
	else
		return false;
};

class Solution
{
public:

	string largestNumber(vector<int> &nums)
	{
		int len = nums.size();
		string res;
		if (len == 0) return res;
		sort(nums.begin(), nums.end(), comp);

		if (nums[0] == 0)
		{
			return "0";
		}
		for (int num : nums)
		{
			res += to_string(num);
		}
		return res;
	}
};

int main()
{
	Solution s;
	vector <int> v{ 3,30,34,5,9 };
	string res = s.largestNumber(v);
	cout << res << endl;

	return 0;
}